/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufrn.engcomp.mpc.util;

import cern.colt.matrix.DoubleMatrix1D;
import cern.colt.matrix.DoubleMatrix2D;
import cern.colt.matrix.impl.DenseDoubleMatrix1D;
import cern.colt.matrix.impl.DenseDoubleMatrix2D;
import org.apache.commons.math.linear.ArrayRealVector;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.linear.RealVector;

/**
 *
 * @author Felipe
 */
public class JOptimizerUtils {

    public static DoubleMatrix2D convertRealMatrixToJOptimizer(RealMatrix matrix) {
        return new DenseDoubleMatrix2D(matrix.getData());
    }

    public static DoubleMatrix1D convertRealVectorToJOptimizer(RealVector vector) {
        return new DenseDoubleMatrix1D(vector.getData());
    }

    public static RealVector convertJOptimizerToRealVector(DoubleMatrix1D vector) {
        return new ArrayRealVector(vector.toArray());
    }

}
